#include "mainwindow.h"
#include <QStyle>
#include <QApplication>

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
{
    /* 设置窗口位置与大小 */
    this->setGeometry(0, 0, 800, 480);

    mToolBar = new QToolBar(this);
    mToolBar->setGeometry(0, 0, 800, 100);

    QStyle* style = QApplication::style();

    QIcon icon = style->standardIcon(QStyle::SP_TitleBarContextHelpButton);

    mToolButton = new QToolButton();
    mToolButton->setIcon(icon);
    mToolButton->setText("帮助");
    mToolButton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
    mToolBar->addWidget(mToolButton);

    connect(mToolButton, &QToolButton::clicked, this, &MainWindow::onToolBarClickListener);
}

MainWindow::~MainWindow()
{

}

void MainWindow::onToolBarClickListener()
{
    this->setStyleSheet(R"(QMainWindow {background-color:rgba(255, 245, 238, 50%)})");
}
